package com.yuxi.config;

import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import redis.clients.jedis.Jedis;

/**
 * Created by yuxi on 16/10/24.
 */
@Configuration
@PropertySource("classpath:application.properties")
public class JedisConfig implements EnvironmentAware {


    private Environment env;

    @Override
    public void setEnvironment(Environment environment) {
        this.env = environment;
    }

    @Bean
    public Jedis getJedis() {
        Jedis jedis = new Jedis(env.getProperty("jedis.host"),
                Integer.valueOf(env.getProperty("jedis.port")));
        return jedis;

    }


}
